<%@ include file="../includes/taglibs.jsp"%>

<div id="mainHorizontal">

	<%
			List components = (List) request.getAttribute("components");
			int counter = 0;
			int separator = 20;
			int columnCount = components.size();
			int totalWidth = 940;
	%>
	<c:forEach items="${components}" var="component" varStatus="status">
		<%
			Integer width = (totalWidth + separator)/columnCount - separator;
			Integer marginRight = separator;
			if (counter==(columnCount-1)) {
				marginRight = 0;
				
				// поправка к последнему блоку
				int correction = totalWidth - ((columnCount * width) + (columnCount-1)*separator);
				width = width + correction;
				
			}
		%>
		<div class="horizontalItem" style="width: <%=width%>px; margin-right: <%=marginRight%>px;">
			<cms:component content="${component}" />
		</div>
		<%
			counter++;
		%>
	</c:forEach>

</div>
